<?
include_once("../../database.php");
include_once("../../backend.php");
include_once("../../login_management.php");
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/scoutingevent.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<link rel="stylesheet" type="text/css" href="../../scouting.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Event Setup | Team Spyder Scouting</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>

<body>
<div class="main">
<div class="top"><l>
<a class="navigation" href="./index.php">Home</a> | 
<a class="navigation" href="./event.php">Event Management</a> | 
<a class="navigation" href="../index.php"> Admin </a> | 
<script type="text/javascript">
function LoadLogin()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("content").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","login.php",true);
xmlhttp.send();
}
</script>

<?
if($logged_in)
{
	echo "<l> Welcome, " . $_SESSION['username'] . " </l>";
	echo "<a class=\"navigation\" href=\"./logout.php\">Log out</a>\n";
}
else
{
	echo "<l> You are not logged in. </l>";
	echo "<a class=\"navigation\" href=\"#\" onclick=\"LoadLogin()\">Log in</a>\n";
}

?>
</l>
</div>
<div class="content"><!-- InstanceBeginEditable name="Content" -->
<?
#if($logged_in)
#{
$q="SELECT * FROM eventlist ORDER BY year DESC";
$result=mysql_query($q)or die(mysql_query());
if(mysql_num_rows($result)==0)
{
	echo "    <h1>Events List</h1>\n";
	echo "<p>No Events have been created yet.</p>";
}
else
{
	?>
    <h1>Events List</h1>
    <table border="2">
    <tr class='tableheader'>
    <td>Year</td>
    <td>Event</td>
    <td>Competition</td>
    <td>Season Name</td>
    <td>Delete</td>
    </tr>
    <?
while($row=mysql_fetch_array($result))
{
	echo "<tr>\n";
	echo "<td>" . $row['year'] . "</td>\n";
	echo "<td>" . $row['event'] . "</td>\n";
	echo "<td>" . $row['competition'] . "</td>\n";
	echo "<td>" . $row['datatable'] . "</td>\n";
	echo "<td><a href='./deleteevent.php?eventid=" . $row['eventid'] . "'>Delete</a></td>\n";
	echo "</td>\n";
}
}
?>
</table>
<h1>Create Season</h1>
<table>
<form action="createseason.php" method="get">
<tr>
<td>Number of fields</td>
<td>Number of events</td>
<td>Create Event</td>
</tr>
<tr>
<td><input type="text" name="fieldnum" value="7" maxlength="10" /></td>
<td><input type="text" name="numevents" value="3" maxlength="10" /></td>
<td><input type="submit" name="Create Event" value="Create Event" /></td>
</tr>
</form>
</table>
<?
if(mysql_num_rows($result)!=0)
{
	
	?>
    <h1>Create Event</h1>
<table>
<form action="createevent.php" method="get">
<tr>
<td>Number of events</td>
<td>Create Event</td>
</tr>
<tr>
<td><input type="text" name="numevents" value="1" maxlength="10" /></td>
<td><input type="submit" name="Create Event" value="Create Event" /></td>
</tr>
</form>
</table>
    <?
}
#}
#else
#{
#	displayLogin();
#}
mysql_close();
?>
<!-- InstanceEndEditable -->
</div>
</div>

</body>
<!-- InstanceEnd --></html>
